package com.lee.lease.web.app.controller.Login;

import com.lee.lease.common.result.Result;
import com.lee.lease.common.threadlocal.LoginUserContext;
import com.lee.lease.common.util.JwtUtil;
import com.lee.lease.web.app.service.UserInfoService;
import com.lee.lease.web.app.vo.user.UserInfoVo;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestHeader;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * ClassName: UserController
 * Package: com.lee.lease.web.app.controller
 * Description:
 */
@RestController
@Tag(name = "登录管理")
@RequestMapping("/app")
public class UserController {

    @Autowired
    private UserInfoService service;

    @Operation(summary = "获取用户信息")
    @GetMapping("/info")
    public Result<UserInfoVo> getInfo(@RequestHeader("access_token") String token){

        Long userId = LoginUserContext.getLoginUser().getUserId();
        UserInfoVo userInfoVo =  service.getUserInfo(userId.intValue());
        return Result.ok(userInfoVo);
    }

}
